<div class="page-header" style="padding-bottom: 0px;">
    <h3>Invoice</h3>
</div>


<div class="row-fluid">
    <div class="span12">
        <h4>Filter</h4>
        <?php echo $this->Form->create('Query', array('id' => 'form-query', 'class' => 'form form-horizontal', 'inputDefaults' => array('label' => false,'div' => false)));?>
        <table class="table ">
            <tr><td>Start Date</td><td>End Date</td><td>Report Type</td><!--<td>Index Number</td><td>Fee Type</td>--></tr>
            <tr>
                <td>
                    <?php echo $this->Form->input('start_dt', array('id'=>'start_dt','placeholder' => 'yyyy-mm-dd', 'default'=>$default_start_dt,'class' => 'input-medium','div' => false, 'label' => false));?>
                </td>
                <td>
                    <?php echo $this->Form->input('end_dt', array('id'=>'end_dt','placeholder' => 'yyyy-mm-dd', 'default'=>$default_end_dt,'class' => 'input-medium','div' => false, 'label' => false));?>
                </td>
               <td>
                    <?php echo $this->Form->input('report_type', array('id'=>'report_type', 'options'=>$report_type_opt, 'default'=>$report_type, 'class' => 'input-medium','div' => false, 'label' => false));?>
                </td>
               <!-- <td>
                    <?php /*echo $this->Form->input('index_no', array('id'=>'index_no','class' => 'input-medium','default'=>$index_no,'div' => false, 'label' => false));*/?>
                <td>
                    <?php /*echo $this->Form->input('fee_type', array('id'=>'fee_type', 'options'=>$fee_types,'default'=>$default_fee_type,'class' => 'input-medium','div' => false, 'label' => false,));*/?>
                </td>-->
            </tr>
            <tr>
                <td colspan="4">
                    <div class="controls">
                        <button type="submit" id="re_query-btn" class="btn btn-primary">Query</button>
                       <!-- <button type="button"  id="print-btn" class="btn">Print</button>
                        <button type="button"  id="export-btn" class="btn">Export</button>-->
                    </div>
                </td>
            </tr>
        </table>
        <?php echo $this->Form->end();?>

        <table id="flex">
            <!-- <thead>
                 <tr><th>Student Name</th><th>Index Number</th><th>Fee Type</th><th>Fee Amount</th><th>Paid</th><th>Balance</th></tr>
             </thead>-->
            <tbody>
            <?php
            $tl_bill = 0;
            foreach ($data_table as $k => $obj) {
                $bill = doubleval($obj['bill']);
                $tl_bill = $tl_bill + $bill;
                $date_format = 'ui';
                if($report_type == 'consolidated' ){
                    $date_format =  'ui_short';
                }

               /* $id  = $obj['id'];
                $btn = $obj['served'];
                if( $obj['served'] == 'No'){
                    $btn= " <button type='button' data-id='$id' class='btn btn-primary btn-small served-btns'>Served</button>";
                }*/

                ?>
                <tr>
                    <td><?php echo $this->App->covertDate($obj['date'],$date_format);?></td>
                    <td><?php echo $controller->formatNumber($bill,'money');?></td>
                </tr>
                <?php
                //}
            }
            if($tl_bill > 0){
                ?>
                <tr>
                    <td><strong>Totals</strong></td>
                    <td><strong><?php echo $controller->formatNumber($tl_bill,'money'); ?></strong></td>
                </tr>
            <?php
            }
            ?>
            </tbody>
        </table>



        <form id="print-export-form" method="post" action="<?php echo $this->Html->url(array('controller' => 'Staff', 'action' => 'print_export_invoice_report')); ?>" target="PrintExportWindow">
            <input type="hidden" name="data_type" id="data_type" value="" />
            <input type="hidden" name="data_start_dt" id="data_start_dt"  value="" />
            <input type="hidden" name="data_end_dt" id="data_end_dt"  value="" />
            <input type="hidden" name="data_program_id" id="data_program_id"  value="" />
            <input type="hidden" name="data_section" id="data_section"  value="" />
        </form>
    </div>
</div>

<?php
    echo $this->Html->script('staff/invoice.js');
?>